<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span {
            color: red;
        }
    </style>
</head>

<body>
    <h1>您当前的位置是: <span id="address"></span></h1>
    <h1>是否GPS定位: <span id="gps"></span></h1>
    <script>
        // 封装 jsonp
        function jsonp(options) {
            let script = document.createElement('script');
            let globFuncName = 'undefined' !== typeof(options.jsonpCallback) ? options.jsonpCallback : 'jsonp_' + new Date().getTime() + parseInt(Math.random() * 1000);
            script.src = options.url + `?callback=${globFuncName}`;
            document.head.appendChild(script).parentNode.removeChild(script);
            window[globFuncName] = function (data) {
                options.success(data);
            }
        }

        jsonp({
            url: 'https://api.asilu.com/geo/',
            success: function (res) {
                document.getElementById("address").innerText = res.address;
                var is_gps = res.gps ? '是' : '否';
                document.getElementById("gps").innerText = is_gps;
            }
        })
    </script>
</body>

</html>